/*Quick Sort Algorithm*/
#include "define.h"
int quick_sort(int a[], int left, int right)
{
	int i, steps = 0;
	int left_hold = left;
	int right_hold = right;
	int pivot = a[left];
	while (left < right){
		while ((a[right] >= pivot) && (left < right)){
			right--;
			steps++;
		}
		if (left != right){
			a[left] = a[right];
			left++;
			steps++;
		}
		while ((a[left] <= pivot) && (left < right)){
			left++;
			steps++;
		}
		if (left != right){
			a[right] = a[left];
			right--;
			steps++;
		}
/*		print_array(a);*/
		steps++;
	}
	/* 
	 * Here  left==right
	 */
	a[left] = pivot;
	if (left_hold < left){
		quick_sort(a, left_hold, left-1);
	}
	if (right_hold > right){
		quick_sort(a, right+1, right_hold);
	}
	return steps;
}
